Defect detection method, computer device and storage medium

ABSTRACT

A product defect detection method which includes acquiring a detection image of a product to be detected is provided. The method further includes dividing the detection image into a first preset number of detection blocks. Once a detection result of each detection block is obtained by inputting each detection block into a preset defect recognition model, according to a position of each detection block in the detection image, a detection result of the product is determined according to the detection result of each detection block.

FIELD

The present disclosure relates to product quality control technologyfield, in particular to a defect detection method, a computer device,and a storage medium.

BACKGROUND

Currently, deep learning network architecture can be used to detectproduct defects. Usually, an image of a product is input into a deeplearning network model to obtain a product detection result. However, aresolution and a size of the input image may affect precision and speedof detection. If the resolution of the input image is high and the sizeis large, although a detection precision is high, the speed of detectionmay be greatly reduced, so it cannot meet requirements of industrialspeed. If the resolution of the input image is reduced, precision ofdetection will be reduced.

BRIEF DESCRIPTION OF THE DRAWINGS

FIG. 1 illustrates a schematic diagram of a computer device according toone embodiment of the present disclosure.

FIG. 2 shows one embodiment of modules of a product defect detectionsystem of the present disclosure.

FIG: 3 shows a flow chart of one embodiment of a product defectdetection method of the present disclosure.

FIG. 4 illustrates a first user interface.

FIG. 5 illustrates a second user interface.

DETAILED DESCRIPTION

In order to provide a more clear understanding of the objects, features,and advantages of the present disclosure, the same are given withreference to the drawings and specific embodiments. It should be notedthat the embodiments in the present disclosure and the features in theembodiments may be combined with each other without conflict.

In the following description, numerous specific details are set forth inorder to provide a full understanding of the present disclosure. Thepresent disclosure may be practiced otherwise than as described herein.The following specific embodiments are not to limit the scope of thepresent disclosure.

Unless defined otherwise, all technical and scientific terms herein havethe same meaning as used in the field of the art technology as generallyunderstood. The terms used in the present disclosure are for thepurposes of describing particular embodiments and are not intended tolimit the present disclosure.

FIG. 1 illustrates a schematic diagram of a computer device of thepresent disclosure.

In at least one embodiment, the computer device 3 includes a storagedevice 31, at least one processor 32. The storage device 31 and the atleast one processor 32 are in electrical communication with each other.

Those skilled in the art should understand that the structure of thecomputer device 3 shown in FIG. 1 does not constitute a limitation ofthe embodiment of the present disclosure. The computer device 3 canfurther include more or less other hardware or software than that shownin FIG. 1, or the computer device 3 can have different componentarrangements.

It should be noted that the computer device 3 is merely an example. Ifanother kind of computer device can be adapted to the presentdisclosure, it should also be included in the protection scope of thepresent disclosure, and incorporated herein by reference

In some embodiments, the storage device 31 may be used to store programcodes and various data of computer programs. For example, the storagedevice 31 may be used to store a product defect detection system 30installed in the computer device 3 and implement completion of storingprograms or data during an operation of the computer device 3. Thestorage device 31 may include Read-Only Memory (ROM), ProgrammableRead-Only Memory (PROM), and Erasable Programmable Read-Only Memory.EPROM), One-time Programmable Read-Only Memory (OTPROM),Electronically-Erasable Programmable Read-Only Memory (EEPROM), CompactDisc (Compact Disc) Read-Only Memory (CD-ROM) or other optical diskstorage, disk storage, magnetic tape storage, or any othernon-transitory computer-readable storage medium that can be used tocarry or store data.

In some embodiments, the at least one processor 32 may be composed of anintegrated circuit. For example, the at least one processor 32 can becomposed of a single packaged integrated circuit or can be composed ofmultiple packaged integrated circuits with the same function ordifferent function. The at least one processor 32 includes one or morecentral processing units (CPUs), one or more microprocessors, one ormore digital processing chips, one or more graphics processors, andvarious control chips. The at least one processor 32 is a control unitof the computer device 3. The at least one processor 32 uses variousinterfaces and lines to connect various components of the computerdevice 3, and executes programs or modules or instructions stored in thestorage device 31, and invokes data stored in the storage device 31 toperform various functions of the computer device 3 and to process data,for example, perform a function of detecting product defect (fordetails, see the description of FIG. 3).

In this embodiment, the product defect detection system 30 can includeone or more modules. The one or more modules are stored in the storagedevice 31 and. are executed by at least one processor (e.g. processor 32in this embodiment), such that a function of detecting product defect(for details, see the introduction to FIG. 3 below) is achieved.

In this embodiment, the product defect detection system 30 can include aplurality of modules. Referring to FIG: 2, the plurality of modulesincludes an obtaining module 301, an execution module 302. The modulereferred to in the present disclosure refers to a series ofcomputer-readable instructions that can be executed by at least oneprocessor (for example, the processor 32), and can complete functions,and can be stored in a storage device (for example, the storage device31 of the computer device 3). In this embodiment, functions of eachmodule will be described in detail with reference to FIG. 3.

In this embodiment, an integrated unit implemented in a form of asoftware module can be stored in a non-transitory readable storagemedium. The above modules include one or more computer-readableinstructions. The computer device 3 or a processor implements the one ormore computer-readable instructions, such that the method for detectingproduct defect shown in FIG. 3 is achieved.

In a further embodiment, referring to FIG. 2, the at least one processor32 can execute an operating system of the computer device 3, varioustypes of applications (such as the product defect detection system 30described above), program codes, and the like.

In a further embodiment, the storage device 31 stores program codes of acomputer program, and the at least one processor 32 can invoke theprogram codes stored in the storage device 31 to achieve relatedfunctions. For example, each module of the product defect detectionsystem 30 shown in FIG. 2 is program code stored in the storage device31. Each module of the product defect detection system 30 shown in FIG.2 is executed by the at least one processor 32, such that the functionsof the modules are achieved, and the purpose of detecting product defect(see the description of FIG. 3 below for details) is achieved.

In one embodiment of the present disclosure, the storage device 31stores one or more computer-readable instructions, and the one or morecomputer-readable instructions are executed by the at least oneprocessor 32 to achieve a purpose of detecting product defect.Specifically, the computer-readable instructions executed by the atleast one processor 32 to achieve the purpose of detecting productdefect is described in detail in FIG. 3 below.

It should be noted that, in other embodiments, the product defectdetection system 30 may also be implemented as an embedded system with astorage device, a processor, and other necessary hardware or software.

FIG. 3 is a flowchart of a product defect detection method according toa preferred embodiment of the present disclosure.

In this embodiment, the product defect detection method can be appliedto the computer device 3. For the computer device 3 that requiresdetecting product defect, the computer device 3 can be directlyintegrated with the function of detecting product defect. The computerdevice 3 can also achieve the function of detecting product defect byrunning a Software Development Kit (SDK).

FIG: 3 shows a flow chart of one embodiment of a product defectdetection method. Referring to FIG. 3, the method is provided by way ofexample, as there are a variety of ways to carry out the method. Themethod described below can be carried out using the configurationsillustrated in FIG. 1, for example, and various elements of thesefigures are referenced in explanation of method. Each block shown inFIG. 3 represents one or more processes, methods, or subroutines,carried. out in the method. Furthermore, the illustrated order of blocksis illustrative only and the order of the blocks can be changed.Additional blocks can be added or fewer blocks can be utilized withoutdeparting from this disclosure. The example method can begin at blockS1.

At block S1, the obtaining module 301 acquires an image of a product tobe detected (for a clear and simple description of the presentdisclosure, the image of the product to be detected is hereinafterreferred to as a “detection image”).

The product to be detected refers to a product that needs to be detectedfor defects. For example, the product to be detected can be a case of amobile phone, a protective cover of a mobile phone, or any othersuitable products.

In one embodiment, the obtaining module 301 may use a camera (not shownin the figure) to photograph the product to be detected to obtain adetection image of the product to be detected. Of course, the detectionimage of the product to be detected can also be stored in the storagedevice 31 in advance, and the obtaining module 301 can directly obtainthe detection image of the product from the storage device 31.

At block S2, the execution module 302 divides the detection image into afirst preset number (for example, 20, 22, or other numerical values) ofblocks (for a clear and simple description of the present disclosure,each of the first preset number of blocks obtained by dividing thedetection image is hereinafter referred to as a “detection block”).

In one embodiment, the execution module 302 also records a position ofeach detection block in the detection image.

In one embodiment, the execution module 302 can establish a coordinatesystem XOY by setting a lower left corner of the detection image as anorigin O, setting a lower horizontal edge of the detection image as an Xaxis, and setting a left vertical edge of the detection image as a Yaxis. The position of each detection block in the detection image refersto a range of position coordinates in the coordinate system XOY Itshould be noted that the coordinate system XOY can also be establishedin other ways, for example, the coordinate system XOY can established bysetting a lower right corner of the detection image as the origin,setting the lower horizontal edge of the detection image as the X axis,and setting a right vertical edge of the detection image as the Y axis.This is only an example and should not be construed as a limitation tothe present disclosure.

In one embodiment, a size of each detection block of the first presetnumber of detection blocks is the same. In other embodiments, the sizeof each detection block of the first preset number of detection blockscan be different.

At block S3, the execution module 302 can obtain a detection result ofeach detection block by inputting each detection block into a presetdefect recognition model according to the position of each detectionblock in the detection image.

In one embodiment, the detection result includes the detection block isflawless or the detection block is flawed.

In an embodiment, the execution module 302 obtains the defectrecognition model, and the obtaining the defect recognition modelincludes (a1)-(a6):

(a1) Collecting a second preset number (for example, 100,000, 200,000 orother values) of defect images.

In one embodiment, a size of each defect image of the second presetnumber of defect images is the same, and the size of each defect imageis the same as the size of the detection image.

In this embodiment, the defect image refers to an image of the producthaving defect.

(a2) Dividing each defect image of the second preset number of defectimages into the first preset number of blocks (each of the preset numberof blocks obtained by dividing the each defect image hereinafterreferred to as “defect block”).

In one embodiment, a size of each defect block of the first presetnumber of defect blocks is the same. In other embodiments, the size ofeach defect block of the first preset number of defect blocks can bedifferent.

(a3) Associating each defect block of the first preset number of defectblocks with a position of each defect block in the corresponding defectimage.

In one embodiment, the execution module 302 can establish a coordinatesystem X′O′Y′ by setting a lower left corner of the defect image as anorigin O′, setting a lower horizontal edge of the defect image as an X′axis, and setting a left vertical edge of the defect image as the Y′axis. The position of each defect block in the corresponding defectimage refers to a range of position coordinates in the coordinate systemX′O′Y′. It should be noted that the method of establishing thecoordinate system X′O′Y′ of the defect image needs to be the same as themethod of establishing the coordinate system XOY of the detection image.

(a4) Taking all of defect blocks corresponding to a same position as atraining sample, thereby obtaining multiple training samples. Eachtraining sample includes all of the defect blocks corresponding to asame position.

(a5) Obtaining multiple defect recognition models by training a neuralnetwork separately based on each of the training samples.

In one embodiment, the training the neural network can be performed bytraining a convolutional neural network model using a neural networktraining algorithm, such as a back-propagation algorithm. The neuralnetwork training algorithm used for training the convolutional neuralnetwork model is a well-known technology, and will not be repeated here.

(a6) Associating each of the multiple defect recognition models with theposition of the corresponding training sample.

According to the above blocks, the execution module 302 takes the defectblocks corresponding to the same position of all the defect images as atraining sample, and trains the defect recognition model based on thetraining sample. Therefore, when performing defect detection, thecorresponding detection model can be invoked for detection according tothe position of the detection block in the detection image.

For example, suppose that each defect image of the second preset numberof defect images is divided into two defect blocks, and the positions ofthe two defect blocks in the defect image are respectively recorded asP1 and P2. Then, the defect blocks each of which is corresponding to theposition P1 among all the defect blocks are used as a first trainingsample, and the defect blocks each of which is corresponding to theposition P2 among all the defect blocks are used as a second trainingsample. A defect recognition model M1 is obtained by training the neuralnetwork using the first training sample, and a defect recognition modelM2 is obtained by training the neural network using the second trainingsample. When the detection image needs to be detected, the detectionimage is divided into two detection blocks, and the positions of the twodetection blocks in the detection image respectively are recorded as P1and P2. Then, the detection block corresponding to the position P1 canbe input to the defect recognition model M1 for detecting defects, andthe detection block corresponding to the position P2 can be input intothe defect recognition model M2 for detecting defects. Such that apurpose of simultaneous detection of different detection blocks isrealized, and a detection rate can be increased.

At block S4, the execution module 302 determines a detection result ofthe product according to the detection result of each detection block.

In this embodiment, when the detection result of each of all detectionblocks indicates that each detection block is flawless, the executionmodule 302 determines that the product is flawless and the productpasses the detection. When at least one detection block is determined tobe flawed according to the detection result, the execution module 302determines that the product is flawed and the product fails thedetection.

In one embodiment, the execution module 302 may generate a first userinterface, and display the detection result of the product on the firstuser interface. The execution module 302 can receive a user's firstinput signal from the first user interface, and display the detectionresult of each detection block of the first preset number of detectionblocks in response to the first input signal.

In one embodiment, the execution module 302 can further display thedetection result of each detection block of the detection imageaccording to the position of each detection block in the detectionimage.

In one embodiment, the execution module 302 can also generate a seconduser interface in response to the first input signal; and display thefirst preset number of patterns on the second user interface, each ofthe first preset number patterns represents a detection result of onedetection block of the first preset number of detection blocks, whereindifferent styles of the pattern indicates different detection results.For example, when the style of a pattern is gray, it means that thecorresponding detection block is flawed and the corresponding detectionblock does not pass the detection; when the style of the pattern is inanother color, such as white, it means that the corresponding detectionblock is flawless and the corresponding detection block passed thedetection.

In one embodiment, the execution module 302 displays a designated buttonon the first user interface, and the first input signal is a signalreceived from the designated button. The signal may be, for example, atouch signal or a double tap signal.

For example, referring to FIG. 4, the execution module 302 generates asecond user interface 6 when a signal from a button 51 on a first userinterface 5 is received. The execution module 302 displays twentypatterns 60 on the second user interface 6, and the twenty patterns 60respectively represent the detection results of twenty detection blocks.A position of each of the twenty patterns 60 on the second. userinterface 6 is corresponding to a position of each of the twentydetection blocks in the detection image. Among them, when the pattern isgray, it means that the corresponding detection block is flawed and doespass the detection, and when the pattern is white, it means that thecorresponding detection block is flawless and has passed the detection.

In one embodiment, the execution module 302 can also associate eachpattern of the first preset number of patterns with a correspondingdetection block; detect second input signal and an input position of thesecond input signal from the second user interface; display a detectionblock corresponding to any pattern of the first preset number ofpatterns on the second user interface when the input position of thesecond input signal is located at the position of the any pattern.

For example, referring to FIG. 5, when the execution module 302 receivesthe users input signal from the position of the gray pattern, theexecution module 302 displays a detection block 61 corresponding to theposition of the gray pattern in the detection image. In one embodiment,the execution module 302 can further display a designated button on thesecond user interface; and switch from the second user interface to thefirst user interface when a third input signal is received from thedesignated button.

For example, referring to FIG. 5, the execution module 302 displays abutton 51 on the second user interface 5. When the execution module 302receives a user input signal from the button 51, the execution module302 switches from the second user interface 6 to the first userinterface 5.

The above description is only embodiments of the present disclosure, andis not intended to limit the present disclosure, and variousmodifications and changes can be made to the present disclosure. Anymodifications, equivalent substitutions, improvements, etc. made withinthe spirit and scope of the present disclosure are intended to beincluded within the scope of the present disclosure. What is claimed is:

1. A product defect detection method applied to a computer device, themethod comprising: acquiring a detection image of a product; dividingthe detection image into a first preset number of detection blocks;obtaining a detection result of each detection block by inputting eachdetection block into a preset defect recognition model, according to aposition of each detection block in the detection image; and determininga detection result of the product according to the detection result ofeach detection block.
 2. The product defect detection method accordingto claim 1, further comprising: collecting a second preset number ofdefect images; dividing each defect image of the second preset number ofdefect images into the first preset number of defect blocks; associatingeach defect block of the first preset number of defect blocks with aposition of each defect block in the corresponding defect image;obtaining a plurality of training samples by setting all of defectblocks corresponding to a same position as a training sample; obtaininga plurality of defect recognition models by training a neural networkseparately based on each of the training samples; and associating eachof the plurality of defect recognition models with the position of thecorresponding training sample.
 3. The product defect detection methodaccording to claim 1, further comprising: generating a first userinterface, and displaying the detection result of the product on thefirst user interface; receiving a first input signal from the first userinterface; and displaying the detection result of each detection blockof the first preset number of detection blocks in response to the firstinput signal.
 4. The product defect detection method according to claim3, further comprising: recording a position of each detection block inthe detection image; displaying the detection result of each detectionblock of the first preset number of detection blocks according to theposition of each detection block in the detection image.
 5. The productdefect detection method according to claim 4, further comprising:generating a second user interface in response to the first inputsignal; and displaying the first preset number of patterns on the seconduser interface, each of the first preset number patterns representing adetection result of one detection block of the first preset number ofdetection blocks, different styles of the pattern indicating differentdetection results.
 6. The product defect detection method according toclaim 5, further comprising: associating each pattern of the firstpreset number of patterns with a corresponding detection block;detecting second input signal and an input position of the second inputsignal from the second user interface; and displaying a detection blockcorresponding to any pattern of the first preset number of patterns onthe second user interface when the input position of the second inputsignal is located at the position of the any pattern.
 7. The productdefect detection method according to claim 6, further comprising:displaying a button on the second user interface; and switching from thesecond user interface to the first user interface when an input signalis received from the button.
 8. A computer device comprising: a storagedevice; at least one processor; and the storage device storing one ormore programs, which when executed by the at least one processor, causethe at least one processor to: acquire a detection image of a product;divide the detection image into a first preset number of detectionblocks; obtain a detection result of each detection block by inputtingeach detection block into a preset defect recognition model, accordingto a position of each detection block in the detection image; anddetermine a detection result of the product according to the detectionresult of each detection block.
 9. The computer device according toclaim 8, wherein the at least one processor is further caused to:collect a second preset number of defect images; divide each defectimage of the second preset number of defect images into the first presetnumber of defect blocks; associate each defect block of the first presetnumber of defect blocks with a position of each defect block in thecorresponding defect image; obtain a plurality of training samples bysetting all of defect blocks corresponding to a same position as atraining sample; obtain a plurality of defect recognition models bytraining a neural network separately based on each of the trainingsamples; and associate each of the plurality of defect recognitionmodels with the position of the corresponding training sample.
 10. Thecomputer device according to claim 8, wherein the at least one processoris further caused to: generate a first user interface, and displayingthe detection result of the product on the first user interface; receivea first input signal from the first user interface; and display thedetection result of each detection block of the first preset number ofdetection blocks in response to the first input signal.
 11. The computerdevice according to claim 10, wherein the at least one processor isfurther caused to: record a position of each detection block in thedetection image; display the detection result of each detection block ofthe first preset number of detection blocks according to the position ofeach detection block in the detection image.
 12. The computer deviceaccording to claim 11, wherein the at least one processor is furthercaused to: generate a second user interface in response to the firstinput signal; and display the first preset number of patterns on thesecond user interface, each of the first preset number patternsrepresenting a detection result of one detection block of the firstpreset number of detection blocks, different styles of the patternindicating different detection results.
 13. The computer deviceaccording to claim 12, wherein the at least one processor is furthercaused to: associate each pattern of the first preset number of patternswith a corresponding detection block; detect second input signal and aninput position of the second input signal from the second userinterface; and display a detection block corresponding to any pattern ofthe first preset number of patterns on the second user interface whenthe input position of the second input signal is located at the positionof the any pattern.
 14. The computer device according to claim 13,wherein the at least one processor is further caused to: display abutton on the second user interface; and switch from the second userinterface to the first user interface when an input signal is receivedfrom the button.
 15. A non-transitory storage medium having instructionsstored thereon, when the instructions are executed by: a processor of acomputer device, the processor is configured to perform a product defectdetection method, wherein the method comprises: acquiring a detectionimage of a product; dividing the detection image into a first presetnumber of detection blocks; obtaining a detection result of eachdetection block by inputting each detection block into a preset defectrecognition model, according to a position of each detection block inthe detection image; and determining a detection result of the productaccording to the detection result of each detection block.
 16. Thenon-transitory storage medium according to claim 15, wherein the methodfurther comprising: collecting a second preset number of defect images;dividing each defect image of the second preset number of defect imagesinto the first preset number of defect blocks; associating each defectblock of the first preset number of defect blocks with a position ofeach defect block in the corresponding defect image; obtaining aplurality of training samples by setting all of defect blockscorresponding to a same position as a training sample; obtaining aplurality of defect recognition models by training a neural networkseparately based on each of the training samples; and associating eachof the plurality of defect recognition models with the position of thecorresponding training sample.
 17. The non-transitory storage mediumaccording to claim 15, wherein the method further comprising: generatinga first user interface, and displaying the detection result of theproduct on the first user interface; receiving a first input signal fromthe first user interface; and displaying the detection result of eachdetection block of the first preset number of detection blocks inresponse to the first input signal.
 18. The non-transitory storagemedium according to claim 17, wherein the method further comprising:recording a position of each detection block in the detection image;displaying the detection result of each detection block of the firstpreset number of detection blocks according to the position of eachdetection block in the detection image.
 19. The non-transitory storagemedium according to claim 18, wherein the method further comprising:generating a second user interface in response to the first inputsignal; and displaying the first preset number of patterns on the seconduser interface, each of the first preset number patterns representing adetection result of one detection block of the first preset number ofdetection blocks, different styles of the pattern indicating differentdetection results.
 20. The non-transitory storage medium according toclaim 19, wherein the method further comprising: associating eachpattern of the first preset number of patterns with a correspondingdetection block; detecting second input signal and an input position ofthe second input signal from the second user interface; and displaying adetection block corresponding to any pattern of the first preset numberof patterns on the second user interface when the input position of thesecond input signal is located at the position of the any pattern.